package druid;

import Utils.JDBCUtils;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;

/*
*   测试Druid的工具类
* */
public class DruidDemo02 {
    public static void main(String[] args) {
        Connection aa = null;
        PreparedStatement bb =null;
        /*
        * 完成添加操作
        * */
        //获取连接
        try {
             aa = JDBCUtils.getConnection();
            //定义sql
            String sql = "insert into account values (null,?,?)";
            //获取pstmt对象
             bb = aa.prepareStatement(sql);
            //给?赋值
            bb.setString(1,"王五");
            bb.setInt(2,3000);
            //执行sql
            int cc = bb.executeUpdate();
            System.out.println(cc);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
          JDBCUtils.close(bb,aa);
        }
    }
}
